<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>JS继承---ES6</h2>
</body>
<script>
    //ES6继承

    //1.第一步先创建一个父类
    class Person {
        //构造器
        constructor(name = '无名', age = 0) {
            this.name = name
            this.age = age
        }

        //原型create方法
        create() {
            console.log(`${this.name}创建新生活`)
        }

        //原型drive方法
        drive() {
            console.log(`${this.name}能开车`)
        }

    }

    class Child extends Person {
        constructor(name, age, address = '地球人') {
            //super就是父类的意思
            super(name, age)
            this.address = address

        }

        //play方法
        play() {
            console.log(`${this.name}能打游戏`)
        }


    }


    const c1 = new Child('王五', 28, '北京')
</script>

</html>